<include file="public@header" />
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header">{:lang('ADMIN_SETTING_UPLOAD')}</div>
            <form method="post" class="layui-form js-ajax-form" role="form" action="{:url('setting/uploadPost')}">
                <div class="layui-card-body">
                    <div class="layui-tab">
                        <ul class="layui-tab-title">
                            <li class="layui-this">
                                <span class="icon-wrapper"><i class="glyphicon glyphicon-open"></i></span>
                                <span class="text-wrapper">{:lang('ADMIN_SETTING_UPLOAD')}</span>
                            </li>
                            <li>
                                <span class="icon-wrapper"><i class="glyphicon glyphicon-fire"></i></span>
                                <span class="text-wrapper">{:lang('WATER_SETTING')}</span>
                            </li>
                        </ul>

                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-card-body">
                                    <div class="layui-form-item">
                                        <label class='control-label layui-col-lg2'>是否重命名文件</label>
                                        <div class="layui-col-lg10">
                                            <php>
                                                $is_rename_yes = $is_rename == 1?"checked":"";
                                            </php>
                                            <input type="checkbox" id="is_rename" name="upload_setting[is_rename]" value="1" title="{:lang('YES')}"  {$is_rename_yes}>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class='control-label layui-col-lg2'>上传文件保存方式</label>
                                        <div class="layui-col-lg10">
                                            <select class="layui-input" name="upload_setting[save_mode]">
                                                <option value="date" <if condition="$save_mode eq date">selected</if>>按日期时间存入</option>
                                                <option value="random" <if condition="$save_mode eq random">selected</if>>按随机数存入</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class='control-label layui-col-lg2'>最大同时上传文件数</label>
                                        <div class="layui-col-lg10">
                                            <input type="text" class="layui-input" name="upload_setting[max_files]" title="最大同时上传文件数" placeholder="最大同时上传文件数" value="{$max_files|default=20}">
                                            <p class="layui-word-aux">多文件上传时,用户能最大同时上传文件数,默认20个</p>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class='control-label layui-col-lg2'>文件分块上传分块大小</label>
                                        <div class="layui-col-lg10">
                                            <input type="text" class="layui-input" name="upload_setting[chunk_size]" title="文件分块上传分块大小KB,1M=1024KB" placeholder="文件分块上传分块大小KB,1M=1024KB" value="{$chunk_size|default=512}">
                                            <p class="layui-word-aux">文件上传采用分块上传,文件分块大小默认512KB,可以根据服务器最大上传限制设置此数值</p>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class='control-label layui-col-lg2'>图片文件</label>
                                        <div class="layui-col-lg10">
                                            <input style="margin-bottom:5px;" type="text" class="layui-input" name="upload_setting[file_types][image][upload_max_filesize]" title="允许上传大小KB,1M=1024KB" placeholder="允许上传大小KB,1M=1024KB" value="{$file_types.image.upload_max_filesize|default=10240}">
                                            <input type="text" class="layui-input" name="upload_setting[file_types][image][extensions]" title="扩展名,以英文逗号分隔" placeholder="扩展名,以英文逗号分隔" value="{$file_types.image.extensions|default='jpg,jpeg,png,gif,bmp'}">
                                            <p class="layui-word-aux">允许上传大小默认为10240KB,1M=1024KB，允许上传格式默认为jpg,jpeg,png,gif,bmp</p>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class='control-label layui-col-lg2'>视频文件</label>
                                        <div class="layui-col-lg10">
                                            <input style="margin-bottom:5px;" type="text" class="layui-input" name="upload_setting[file_types][video][upload_max_filesize]" title="允许上传大小KB,1M=1024KB" placeholder="允许上传大小KB,1M=1024KB" value="{$file_types.video.upload_max_filesize|default=10240}">
                                            <input type="text" class="layui-input" name="upload_setting[file_types][video][extensions]" title="扩展名,以英文逗号分隔" placeholder="扩展名,以英文逗号分隔" value="{$file_types.video.extensions|default='mp4,avi,wmv,rm,rmvb,mkv'}">
                                            <p class="layui-word-aux">允许上传大小默认为102400KB,1M=1024KB，允许上传格式默认为mp4,avi,wmv,rm,rmvb,mkv</p>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class='control-label layui-col-lg2'>音频文件</label>
                                        <div class="layui-col-lg10">
                                            <input style="margin-bottom:5px;" type="text" class="layui-input" name="upload_setting[file_types][audio][upload_max_filesize]" title="允许上传大小KB,1M=1024KB" placeholder="允许上传大小KB,1M=1024KB" value="{$file_types.audio.upload_max_filesize|default=10240}">
                                            <input type="text" class="layui-input" name="upload_setting[file_types][audio][extensions]" title="扩展名,以英文逗号分隔" placeholder="扩展名,以英文逗号分隔" value="{$file_types.audio.extensions|default='mp3,wma,wav'}">
                                            <p class="layui-word-aux">允许上传大小默认为10240KB,1M=1024KB，允许上传格式默认为mp3,wma,wav</p>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class='control-label layui-col-lg2'>附件</label>
                                        <div class="layui-col-lg10">
                                            <input type="text" style="margin-bottom:5px;" class="layui-input" name="upload_setting[file_types][file][upload_max_filesize]" title="允许上传大小KB,1M=1024KB" placeholder="允许上传大小KB,1M=1024KB" value="{$file_types.file.upload_max_filesize|default=10240}">
                                        
                                            <input type="text" class="layui-input" name="upload_setting[file_types][file][extensions]" title="扩展名,以英文逗号分隔" placeholder="扩展名,以英文逗号分隔" value="{$file_types.file.extensions|default='txt,pdf,doc,xls,xlsx,ppt,pptx,zip,rar'}">
                                            <p class="layui-word-aux">允许上传大小默认为10240KB,1M=1024KB，允许上传格式默认为txt,pdf,doc,xls,xlsx,ppt,pptx,zip,rar</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item">
                                <div class="layui-card-body">
                                    <!-- <div class="layui-form-item">
                                        <label class="control-label layui-col-lg2">是否设置水印</label>
                                        <div class="layui-col-lg10">
                                            <select class="layui-input" name="water_settings[open_water]" >
                                                <option value="0">否</option>
                                                <php>$open_water_selected = empty($water_settings['open_water'])?'':'selected';</php>
                                                <option value="1" {$open_water_selected}>是</option>
                                            </select>
                                        </div>
                                    </div> -->

                                    <!-- 水印方式 -->
                                    <div class="layui-form-item">
                                        <php>
                                            $water_method0 = $water_settings['water_method']==0 ? "checked" : "";
                                            $water_method1 = $water_settings['water_method']==1 ? "checked" : "";
                                        </php>
                                        <label class="control-label layui-col-lg2">{:lang('WATER_METHOD')}</label>
                                        <div class="layui-col-lg10">
                                            <div id="img_water" class="layui-inline">
                                                <input type="radio" id="water_method0" name="water_settings[water_method]" value="0" title="{$lang['water_method_values'][0]}" {$water_method0}>
                                            </div>
                                            <div id="text_water" class="layui-inline">
                                                <input type="radio" id="water_method1" name="water_settings[water_method]" value="1" title="{$lang['water_method_values'][1]}" {$water_method1}>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- 水印位置 -->
                                    <div class="layui-form-item">
                                        <label class="control-label layui-col-lg2">{:lang('WATER_LOCATION')}</label>
                                        <div class="layui-col-lg10">
                                            <div class="Grids9 clearfix">
                                                <a href="javascript:;" val="1" <eq name="water_settings.water_w" value="1">class="hover"</eq> >{$lang['water_location_values'][1]}</a><!--上左-->
                                                <a href="javascript:;" val="2" <eq name="water_settings.water_w" value="2">class="hover"</eq> >{$lang['water_location_values'][2]}</a><!--上中-->
                                                <a href="javascript:;" val="3" <eq name="water_settings.water_w" value="3">class="hover"</eq> >{$lang['water_location_values'][3]}</a><!--上右-->
                                                <a href="javascript:;" val="4" <eq name="water_settings.water_w" value="4">class="hover"</eq> >{$lang['water_location_values'][4]}</a><!--中左-->
                                                <a href="javascript:;" val="5" <eq name="water_settings.water_w" value="5">class="hover"</eq> >{$lang['water_location_values'][5]}</a><!--中中-->
                                                <a href="javascript:;" val="6" <eq name="water_settings.water_w" value="6">class="hover"</eq> >{$lang['water_location_values'][6]}</a><!--中右-->
                                                <a href="javascript:;" val="7" <eq name="water_settings.water_w" value="7">class="hover"</eq> >{$lang['water_location_values'][7]}</a><!--下左-->
                                                <a href="javascript:;" val="8" <eq name="water_settings.water_w" value="8">class="hover"</eq> >{$lang['water_location_values'][8]}</a><!--下中-->
                                                <a href="javascript:;" val="9" <eq name="water_settings.water_w" value="9">class="hover"</eq> >{$lang['water_location_values'][9]}</a><!--下右-->
                                            </div>
                                            <input id="WatermarkPosition" name="water_settings[water_w]" type="hidden" value="{$water_settings.water_w}">
                                        </div>
                                    </div>

                                    
                                    <div class="layui-form-item img_water">
                                        <label class="control-label layui-col-lg2">{:lang('WATER_PICTURE')}</label>
                                        <div class="layui-col-lg10 upload-image">
                                            <input type="hidden" name="water_settings[water_img]" id="thumbnail" value="{$water_settings.water_img}">
                                            <a href="javascript:uploadWaterImage('{:lang('UPLOAD_IMAGE')}','#thumbnail');">
                                                <if condition="$water_settings.water_img">
                                                    <img src="{:cmf_get_image_preview_url($water_settings.water_img)}"
                                                         id="thumbnail-preview"
                                                         width="135"/>
                                                
                                                <else/>
                                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                                         id="thumbnail-preview"
                                                         width="135"/>
                                                </if>
                                            </a>
                                            <input type="button" class="layui-btn layui-btn-danger layui-btn-md btn-cancel-thumbnail" onclick="$('#thumbnail-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#thumbnail').val('');return false;" value="{:lang('CANCEL_PICTURE')}">
                                            <p class="layui-word-aux">{:lang('WATER_PICTURE_TIPS')}</p>
                                        </div>
                                    </div>

                                    <div class="layui-form-item img_water">
                                        <label class="control-label layui-col-lg2">透明度</label>
                                        <div class="layui-col-lg10">
                                            <input type="text" class="layui-input" id="input-site_admin_email" name="water_settings[transparency]" value="{$water_settings.transparency|default='20'}">
                                            <p class="layui-word-aux">透明度0~100</p>
                                        </div>
                                    </div>

                                    <div class="layui-form-item zi_water">
                                        <label class="control-label layui-col-lg2">水印文字</label>
                                        <div class="layui-col-lg10">
                                            <input type="text" class="layui-input" id="input-site_admin_zi" name="water_settings[water_zi]" value="{$water_settings.water_zi}">
                                        </div>
                                    </div>

                                    <div class="layui-form-item zi_water">
                                        <label class="control-label layui-col-lg2">字体</label>
                                        <div class="layui-col-lg10">
                                            
                                            <input type="text" class="layui-input" id="input-site_admin_zi" name="water_settings[water_family]" value="{$water_settings.water_family|default='msyh.ttf'}">

                                            <p class="layui-word-aux">请将字体文件放入"根目录font"下</p>
                                        </div>
                                    </div>

                                    <div class="layui-form-item zi_water">
                                        <label class="control-label layui-col-lg2">字号</label>
                                        <div class="layui-col-lg10">
                                            
                                            <input type="text" class="layui-input" id="input-site_admin_zi" name="water_settings[water_font]" value="{$water_settings.water_font|default='20'}">
                                        </div>
                                    </div>
                                    <div class="layui-form-item zi_water">
                                        <label class="control-label layui-col-lg2">字体颜色</label>
                                        <div class="layui-col-lg10">
                                            
                                            <input type="text" class="layui-input" id="input-site_admin_zi" name="water_settings[water_color]" value="{$water_settings.water_color|default='#ffffff'}">
                                        </div>
                                    </div>

                                    <div class="layui-form-item zi_water">
                                        <label class="control-label layui-col-lg2">偏移量</label>
                                        <div class="layui-col-lg10">
                                            
                                            <input type="text" class="layui-input" id="input-site_admin_zi" name="water_settings[water_offset]" value="{$water_settings.water_offset|default='0'}">
                                        </div>
                                    </div>

                                    <div class="layui-form-item zi_water">
                                        <label class="control-label layui-col-lg2">倾斜角度</label>
                                        <div class="layui-col-lg10">
                                            
                                            <input type="text" class="layui-input" id="input-site_admin_zi" name="water_settings[water_angle]" value="{$water_settings.water_angle|default='0'}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-group clearfix">
                        <div class="layui-col-lg-offset2 layui-col-lg10">
                            <button type="submit" class="layui-btn layui-btn-normal width-100 padding-sm js-ajax-submit" data-refresh="1">{:lang('SAVE')}</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
<include file="public@footer"/>

<script>
    $(function(){
        changeWaterMethod({$water_settings['water_method']});
    })
    
    // 切换水印类型
    function changeWaterMethod(val){
        if( val == 1 ){
            $('.zi_water').show();
            $('.img_water').hide();
        }else{
            $('.img_water').show();
            $('.zi_water').hide();
        }
    }

    // 点击更换水印位置
    $(".Grids9 a").on("click",function(){
        $(this).addClass("hover").siblings("a").removeClass("hover");
        $("#WatermarkPosition").val($(this).attr("val"));
    })

    $('#img_water').on('click', '.layui-form-radio',function(){
        changeWaterMethod(0);
    });

    $('#text_water').on('click', '.layui-form-radio',function(){
        changeWaterMethod(1);
    });
</script>
